package cn.edu.bupt.scidata.mapper;

import cn.edu.bupt.scidata.model.paper.Paper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PaperkeyMapper {

//    @Select("SELECT paper.quote,paper.title,paper.keywords,DATE_FORMAT( paper.time, \"%Y\" ) AS time,paper.author FROM paper force index (quo) WHERE id in ( SELECT b.paper_id FROM paper_clf b FORCE INDEX (paper_clf_paper_id_classify_id_0e86387a_uniq) inner JOIN paper_clf a  FORCE INDEX (paper_clf_paper_id_classify_id_0e86387a_uniq) ON a.paper_id = b.paper_id  AND a.classify_id = #{a_id}  AND b.classify_id = #{b_id} ) ORDER BY quote DESC ")
//    @Select("SELECT * FROM paper WHERE id IN (SELECT a.paper_id FROM paper_clf a left JOIN paper_clf b ON a.paper_id = b.paper_id WHERE a.classify_id = #{a_id} AND b.classify_id = #{b_id}) ORDER BY quote DESC  ")
    @Select("SELECT paper.quote, paper.title, paper.keywords,DATE_FORMAT( paper.time, \"%Y-%m-%d\" ) AS time,paper.author  FROM paper FORCE INDEX ( quo ) WHERE id IN (SELECT paper_id FROM paper_key WHERE keyword_id = #{keyid})")
    List<Paper> querypaper(int keyid);
}
